{% load debate_tags static i18n %}

{% regroup statistics.motions by round as motions_by_round %}

{% for round, motions in motions_by_round %}

  <div class="list-group mt-3">

    <div class="list-group-item disabled text-center h5" style="margin-bottom:0;">
      <span class="badge badge-secondary">{{ round.name }}</span>
    </div>

    {% for r_motion in motions %}
      {% with motion=r_motion.motion %}
      <div class="list-group-item px-1 px-md-4 pb-0 text-center">

        <h4 class="mb-3 mt-1">
          {{ motion.text }} <small class="text-muted d-md-inline d-none">({{ motion.reference }})</small>
          {% if motion.nrounds > 1 %}
            {% for m_round in motion.rounds.all %}
              <span class="badge mr-2 float-right badge-light">
                {{ m_round.abbreviation }}
              </span>
            {% endfor %}
          {% endif %}
        </h4>

        {% if motion.info_slide %}
          <span class="h6 badge badge-light text-secondary mx-auto mb-3 mt-0 hover-target"
                data-toggle="modal" data-target="#info_{{ motion.id }}">
            {% trans "View Info Slide" %}
          </span>
          {% include 'motions_info.html' %}
        {% endif %}

        <div class="row">

          {% if pref.teams_in_debate == 'two' %}
            {% include "motion_statistics_twoteam.html" with motion=r_motion %}
          {% elif pref.teams_in_debate == 'bp' and round.stage == round.STAGE_ELIMINATION %}
            {% include "motion_statistics_bp_elim.html" with motion=r_motion %}
          {% elif pref.teams_in_debate == 'bp' and round.stage == round.STAGE_PRELIMINARY %}
            {% include "motion_statistics_bp_prelim.html" with motion=r_motion %}
          {% endif %}

        </div>

      </div>
      {% endwith %}
    {% endfor %}

  </div>
{% endfor %}
